package com.ddtech.business.web.controller;


import com.ddtech.business.web.entity.Answer;
import com.ddtech.business.web.query.AnswerQuery;
import com.ddtech.business.web.res.AnswerCheckVo;
import com.ddtech.business.web.service.AnswerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 问答表 前端控制器
 * </p>
 *
 * @author bin_pu
 * @since 2023-02-06
 */
@Api(tags = "业务-问答表")
@RestController
@RequestMapping("/web/answer")
public class AnswerController {

    @Autowired
    private AnswerService answerService;

    @ApiOperation(value = "分页查询问答表")
    @GetMapping(value = "/page-list")
    public ResponseEntity getPageList(AnswerQuery answerQuery) {
        return new ResponseEntity(answerService.pageList(answerQuery), HttpStatus.OK);
    }

    @ApiOperation(value = "查询课程、个人专家答疑-移动端、PC端")
    @GetMapping(value = "/page-list-pc")
    public ResponseEntity getPageListPc(AnswerQuery answerQuery) {
        return new ResponseEntity(answerService.getPageListPc(answerQuery), HttpStatus.OK);
    }

    @ApiOperation(value = "查询待回答的答疑、问题列表-移动端、PC端")
    @GetMapping(value = "/page-no-answer-list-pc")
    public ResponseEntity getPageNoAnswerListPc(AnswerQuery answerQuery) {
        return new ResponseEntity(answerService.getPageNoAnswerListPc(answerQuery), HttpStatus.OK);
    }

    @ApiOperation(value = "新增问答")
    @PostMapping(value = "/create")
    public ResponseEntity create(@RequestBody Answer answer) {
        answerService.create(answer);
        return new ResponseEntity(true,HttpStatus.OK);
    }

    @ApiOperation(value = "培训课程新增问答")
    @PostMapping(value = "/train-create")
    public ResponseEntity trainCreate(@RequestBody Answer answer) {
        answerService.trainCreate(answer);
        return new ResponseEntity(true,HttpStatus.OK);
    }

    @ApiOperation(value = "删除问答")
    @PostMapping(value = "/del/{id}")
    public ResponseEntity del(@PathVariable String id) {
        answerService.del(id);
        return new ResponseEntity(HttpStatus.OK);
    }

    @ApiOperation(value = "审核问答")
    @PostMapping(value = "/check")
    public ResponseEntity check(@RequestBody AnswerCheckVo checkVo) {
        answerService.checkAll(checkVo);
        return new ResponseEntity<>(HttpStatus.OK);
    }
}
